
var app = getApp()

Page({

  /**
   * 页面的初始数据
   */
  data: {
    device_data: [],
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {


    const db = wx.cloud.database()
    var that = this
    db.collection('device_data').get({
      success: function (res) {
        // console.log(res.data)
        that.setData({
          device_data: res.data
        })
      }
    })
  },

  godetail: function (event) {
    var index = event.currentTarget.dataset.index
    // console.log(app.globalData.user)
    // console.log(event.currentTarget.dataset.index)
    app.globalData.device_detail = this.data.device_data[index]
    wx.navigateTo({
      url: './detail/detail',
    })
  },
  predict: function(){
    wx.navigateTo({
      url: './predict/predict',
    })
  },
  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {

  }
})